<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>全部已分配订单</title>
    <c:import url="../../header.jsp"/>
    <script> var ALLOT_REFUSED = '${ALLOT_REFUSED}';</script>
</head>
<body>
<div class="body-main">
    <form action="" id="allocatedScOrderForm">
        <div class="titleSearch">
            <div class="layui-inline">
                <label>客户电话：</label>
                <div class="layui-input-inline">
                    <input name="customerPhone" type="text" class="input-style" maxlength="50"
                           placeholder="请输入客户号码">
                </div>
            </div>
            <div class="layui-inline">
                <label>订单来源：</label>
                <div class="layui-input-inline">
                    <select class="select-style" id="signOrgId" name="signOrgId">
                        <option value>请选择</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label>生产所属事业部：</label>
                <div class="layui-input-inline">
                    <select class="select-style" id="productOrgId" name="productOrgId">
                        <option value>请选择</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label>业务类型：</label>
                <div class="layui-input-inline">
                    <div id="business_typeCode">
                        <input type="hidden" name="businessType" class="plug-in-msg"/>
                        <input type="hidden" name="typeCode" id="typeCode" class="plug-in-code"/>
                        <input type="text" readonly placeholder="请选择业态" class="chose-plugIn layui-input"
                               name="businessTypeName">
                        <div class="bus-picker">
                            <div class="bus-picker-tab">
                                <a href="javascript:void(0);" class="active">请选择业态</a>
                            </div>
                            <div class="bus-picker-content"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-inline">
                <label>分配时间：</label>
                <div class="layui-inline">
                    <input type="text" name="allotDateStart" placeholder="开始时间" class="Wdate input-style" id="d4311"
                           onFocus="var d4312=$dp.$('d4312'); WdatePicker({onpicked:function(){d4312.focus();}, maxDate:'#F{ $dp.$D(\'d4312\')}', dateFmt:'yyyy-MM-dd'})">
                </div>
                <span>~</span>
                <div class="layui-inline">
                    <input type="text" name="allotDateEnd" placeholder="结束时间" class="Wdate input-style" id="d4312"
                           onFocus="WdatePicker({minDate:'#F{$dp.$D(\'d4311\')}', dateFmt:'yyyy-MM-dd'})">
                </div>
            </div>
            <div class="layui-inline">
                <label>分配人：</label>
                <div class="layui-input-inline">
                    <select id="allotUserId" name="allotUserId" class="allotUserIdChooseUser">
                        <option value="">--请选择--</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label>流程人员：</label>
                <div class="layui-input-inline">
                    <select id="flowUserId" name="flowUserId" class="flowUserIdChooseUser">
                        <option value="">--请选择--</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label>是否需办理：</label>
                <div class="layui-input-inline">
                    <select id="isNeedDispose" name="isNeedDispose"  class="select-style" >
                        <option value="">请选择</option>
                        <option value="0">需要办理</option>
                        <option value="1">无需办理</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label>关键字：</label>
                <div class="layui-input-inline">
                    <input name="searchKey" type="text" class="input-style" maxlength="50" style="width:250px"
                           placeholder="客户名/订单编号/生产订单编号/合同编号">
                </div>
            </div>

            <div class="layui-inline">
                <button class="layui-btn layui-btn-mini layui-btn-normal" type="button" onclick="dataTableReload()">搜索</button>
                <button class="layui-btn layui-btn-mini layui-btn-primary" type="button" onclick="cleanSearch()">清空</button>
                <d:hasUrlAuth authCode="ZZSC_ALLOCATED_EXPORT">
                    <button class="layui-btn layui-btn-mini layui-btn-green" type="button" onclick="export_data()">导出</button>
                </d:hasUrlAuth>
            </div>
        </div>
    </form>
    <div class="table-conter">
    </div>
    <div class="table-body">
        <!--表格 start-->
        <table id="allocatedScOrderTable" class="cell-border crm-table columnsHidden dataTable">
            <thead>
            <tr>
                <th width="20"><input type="checkbox" class="checkall"/></th>
                <th width="50">序号</th>
                <th>订单来源</th>
                <th>订单编号</th>
                <th>生产订单编号</th>
                <th>合同编号</th>
                <th>客户</th>
                <th>业务类型</th>
                <th>订单产品</th>
                <th>销售订单备注</th>
                <th>是否需办理</th>
                <th>分配时间</th>
                <th>分配人</th>
                <th>流程人员</th>
                <th>流程部门</th>
                <th>合同周期</th>
            </tr>
            </thead>
            <tbody>

            </tbody>
        </table>
        <!--表格 end-->
    </div>
</div>
<c:import url="/WEB-INF/jsp/footer.jsp"/>
<script type="text/javascript">
    var NORMAL = '${NORMAL}', TIME_OUT = '${TIME_OUT}';
</script>
<script type="text/javascript"
        src="${basePath}/static/js/choose.extend.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/zzsc/production/sc_common.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/zzsc/common/call_common.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/zzsc/inprocess/inprocess_list.js?v=${version}"></script>
<script src="${rootUrl}/static/js/zzsc/common/sc_chooseUser.js?v=${version}" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
    Plug.plug_in("post", "${basePath}/zzsc/common/tree_book_list.do?code=BUS_YT_ZZ&&type=2&&level=3", "#business_typeCode", '选择业态', '', true, 'BUS_YT_ZZ', '', '');
</script>
<script type="text/javascript">
    $(function () {
        syb("#signOrgId");//初始化事业部
        syb("#productOrgId");//初始化事业部

        //初始化分配人员选择
        chooseUserPlug.init($('.allotUserIdChooseUser'), {
            url: sysInfo.basePath + '/zzsc/common/find_user_choose.do',
            // multiple:true,// 单选false或不写该参数，多选true
            otherParam: {
                /**
                 * type: 用户信息选择类型（必填）
                 *       all:全部用户，division：当前登录人所在事业部，department:当前登录人所在部门及以下，role: 查询指定角色用户，
                 * roleCode : 角色Code，（type为role时，必填）
                 * locked: 用户状态，（选填，默认全部状态）
                 *      0、正常；1、锁定；2、离职
                 */
                type: 'role',
                roleCode: 'ZZSC_DISTRIBUTION_USER',
                locked: '0'
            }

        });
        //初始化分配人员选择
        chooseUserPlug.init($('.flowUserIdChooseUser'), {
            url: sysInfo.basePath + '/zzsc/common/find_user_choose.do',
            // multiple:true,// 单选false或不写该参数，多选true
            otherParam: {
                /**
                 * type: 用户信息选择类型（必填）
                 *       all:全部用户，division：当前登录人所在事业部，department:当前登录人所在部门及以下，role: 查询指定角色用户，
                 * roleCode : 角色Code，（type为role时，必填）
                 * locked: 用户状态，（选填，默认全部状态）
                 *      0、正常；1、锁定；2、离职
                 */
                type: 'role',
                roleCode: 'ZZSC_FLOW_USER',
                locked: '0'
            }

        });

    });

    function export_data() {
        var paras = $('#allocatedScOrderForm').serialize2object();
        if (Object.keys(paras).length == 0) {
            DGG.Warning('请加入搜索条件后导出！');
            return;
        }
        export_table('/sc/all/allocatedscorde_export.do', getSearchData());
    }

    // 获取搜索数据
    function getSearchData() {
        return $.extend($('.main-title').serializeJson(), $('.titleSearch').serializeJson());
    }

    $(document).ready(function () {
        //初始化dataTable列表
        //初始化dataTable列表
        table = $('#allocatedScOrderTable').dataTableExtend({
            "ajax": {"url": "${basePath}/sc/all/allocatedScOrderJson.do", "type": "post"},
            "fnServerParams": function (aoData) {
                aoData = $.extend(aoData, getSearchData());
                return aoData;
            },
            "scrollX": "true",//是否开启横项滚动
            "fixedColumns": {//锁定列，只有开启scrollX时才生效
                "leftColumns": 3,//左侧锁定2列
                "rightColumns": 1//右侧锁定1列
            },
            "aoColumns": [
                {
                    "orderable": false,
                    "data": "id",
                    "render": function (data, type, full, meta) {
                        return '<input type="checkbox"  name="ids" class="checkchild"  value="' + data + '" />';
                    }
                }
                , {
                    "orderable": false,
                    "render": function (data, type, full, meta) {
                        return meta.row + 1;
                    }
                }, {
                    "orderable": false,
                    "data": "signOrgName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                }, {
                    "orderable": false,
                    "data": "orderNo",
                    "render": function (data, type, full, meta) {
                        return ('<a href=\'javascript:void(0)\' ti  onclick="openBusinessDetail(\'' + full.orderNo + '\',\'' + full.orderId + '\')" /><span class="layui-table-link">' + data + '</span></a>&nbsp;');
                    }
                }, {
                    "orderable": false,
                    "data": "scProductOrderNo",
                    "render": function (data, type, full, meta) {
                        var result = "";
                        result += '<a href="javascript:;"  class="layui-table-link" onclick="openOrderInfoDetail(\'' + full.scProductOrderNo + '\',\'' + full.id + '\')" /><p>' + data + '</p></a>';
                        return result;
                    }
                },
                {
                    "orderable": false,
                    "data": "contractNo",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "orderable": false,
                    "data": "customerName",
                    "render": function (data, type, full, meta) {
                        return emptyStringConvert(full.customerName) + '<p>' + emptyStringConvert(full.customerPhone) + '</p>';
                    }
                },
                {
                    "orderable": false,
                    "data": "businessProductName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "orderable": false,
                    "data": "productName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "orderable": false,
                    "data": "orderRemark",
                    "render": function (data, type, full, meta) {
                        if(data){
                            return  '<div class="line2" style="min-width: 120px" title="'+data+'">'+data+'</div> ';
                        }else{
                            return '';
                        }
                    }
                },
                {
                    "orderable": false,
                    "data": "isNeedDispose",
                    "render": function (data, type, full, meta) {
                        return data;
                    }
                }, {
                    "orderable": true,
                    "data": "allotDate",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                },
                {
                    "orderable": false,
                    "data": "allotUserName",
                    "render": function (data, type, full, meta) {
                        return data ? data : '';
                    }
                }, {
                    "orderable": false,
                    "data": "flowUserName",
                    "render": function (data, type, full, meta) {
                        if (full.allotWay == 'SC_GENERAL_ALLOT01') {//分配生产人
                            return data ? data : '';
                        }
                        else if (full.allotWay == 'SC_GENERAL_ALLOT02') {//分配负责人
                            return full.productUserName ? full.productUserName : '';
                        }else{
                            return '';
                        }
                    }
                }
                , {
                    "orderable": false,
                    "data": "flowUserOrgName",
                    "render": function (data, type, full, meta) {
                        if (full.allotWay == 'SC_GENERAL_ALLOT01') {//分配生产人
                            return data ? data : '';
                        }
                        else if (full.allotWay == 'SC_GENERAL_ALLOT02') {//分配负责人
                            return full.productUserOrgName ? full.productUserOrgName : '';
                        }else{
                            return '';
                        }
                    }
                },
                {
                    "orderable": false,
                    "data": "contractStartDate",
                    "render": function (data, type, full, meta) {
                        return data ? data.replace(new RegExp("-",'g'),"")+"-"+full.contractEndDate.replace(new RegExp("-",'g'),"") : '';
                    }
                }],
            "columnDefs": [{
                targets: [3], //第1，2，3列
                createdCell: function (td, cellData, rowData, row, col) {
                    /*  var status = rowData.allotTimeStatus;
                     if (status && status.indexOf(TIME_OUT) > -1) {
                         $(td).parent().addClass("bgGreen")
                     } */
                }
            }]
        });
    });
</script>
</body>

</html>